package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;

import java.util.List;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.VideoBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.VideoitemViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by neusoft on 2017/10/13.
 */

public class VideoListAdapter extends BaseListAdapter {
    public VideoListAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_video_list, parent, false);
        VideoitemViewHolder viewHolder = new VideoitemViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        VideoBean videoBean = (VideoBean) data.get(position);
        VideoitemViewHolder viewHolder = (VideoitemViewHolder) holder;

        final int clubId = videoBean.getC_id();
        String videoName = videoBean.getCv_name();

        viewHolder.videoNameView.setText(videoName);

        Uri uri = Uri.parse(BASE_URI+"videoMp4/"+videoBean.getCv_address());
        viewHolder.videoView.setMediaController(new MediaController(context));
        viewHolder.videoView.setVideoURI(uri);

    }
}
